//Page Object
import {BannerList,nineList,shopList} from "../../utils/http";
Page({
    data: {
      list:[],
      nineList:[],
      xsList:[],
      shopList:[],
      timeData: {},
      id:"",
      ind:""
    },
    
       //跳转
   jump(e){
    console.log(e);
    this.setData({
      id:e.currentTarget.dataset.index
    })
   for(var i=0;i<this.data.nineList.length;i++){
        if(this.data.id==i){
          this.setData({
            ind:this.data.nineList[i].id
          })

        }
   }
    wx.reLaunch({
      url:`/pages/classify/classify?id=${this.data.id}&ind=${this.data.ind}`
    })
  },

  onChange(e) {
    this.setData({
      timeData: e.detail,
    });
  },

    //options(Object)
    onLoad: function(options) {
        //轮播
        BannerList().then(res=>{
            //截取初始轮播图
            var arr=res.data.splice(3,3)
            var brr=res.data.splice(2,1)
            this.setData({
                list:arr,
                xsList:brr
            })
           }).catch(res=>{
                console.log(res)
           })
        //9宫格
        nineList().then(res=>{
            //截取初始轮播图
            this.setData({
                nineList:res.data
            })
            //console.log(this.data.nineList)
           }).catch(res=>{
                console.log(res)
           })
            //商品
            shopList().then(res=>{
            //截取初始轮播图
            this.setData({
                shopList:res.data
            })
           }).catch(res=>{
                console.log(res)
           })
    }, 
    onReady: function() {
        
    },
    onShow: function() {
        
    },
    onHide: function() {

    },
    onUnload: function() {

    },
    onPullDownRefresh: function() {

    },
    onReachBottom: function() {

    },
    onShareAppMessage: function() {

    },
    onPageScroll: function() {

    },
    //item(index,pagePath,text)
    onTabItemTap:function(item) {

    }
});
  